package sctu.edu.java.year2016.team07.liaohengju.day20160524.chapter6_2;

import com.sun.corba.se.impl.ior.FreezableList;
import com.sun.deploy.panel.DeleteFilesDialog;

/**
 * Created by hengju on 2016/5/24.
 * 2、前面介绍了去除字符串中所有空格的两种方法，试着不用这两种方法，只利用for循环 和if条件语句实现去除空格。
 */
public class Zuoye6_2 {
    public static void main(String[] args) {
        char a[] = {'j', 'a', 'v', 'a', ' ', ' ', 'I', ' ', 'l', 'o', 'v', 'e', ' ', 'y', 'o', 'u'};
        String s = new String(a);
        System.out.println("将要改动的字符串是：" + s);
        char b[];
        b = new char[a.length];
        System.out.print("去除空格后的字符串为：");
        for (int i = 0; i < a.length; i++) {
            if (a[i] != ' ') {
                b[i] = a[i];
                System.out.print(b[i]);
            }
        }
    }
}
